package edu.whu.demo.service.impl;

import edu.whu.demo.Dto.UserDto;
import edu.whu.demo.dao.SupplierDao;
import edu.whu.demo.domain.Commodity;
import edu.whu.demo.dao.CommodityDao;
import edu.whu.demo.domain.User;
import edu.whu.demo.service.ICommodityService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.stereotype.Service;
import org.yaml.snakeyaml.events.Event;

import javax.annotation.Resource;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author 王冠儒
 * @since 2023-10-22
 */
@Service
public class CommodityServiceImpl extends ServiceImpl<CommodityDao, Commodity> implements ICommodityService {
    @Resource
    private CommodityDao commodityDao;

    @Cacheable(cacheNames = "commodity",key = "#id",condition = "#id>0")
    public Commodity getCommodity(int id){
        return commodityDao.selectById(id);
    }


    @CacheEvict(cacheNames = "commodity",key = "#id")
    public void deleteUser(int id) {
        commodityDao.deleteById(id);
    }



}
